home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / programming / other / python-1.52 / lib / python1.5 / test / test_nis.py < prev    next >
Text File  |  1999-06-14  |  829b  |  33 lines

  1. from test_support import verbose, TestFailed
  2. import nis
  3.  
  4. print 'nis.maps()'
  5. try:
  6.     maps = nis.maps()
  7. except nis.error, msg:
  8.     # NIS is probably not active, so this test isn't useful
  9.     if verbose:
  10.         raise TestFailed, msg
  11.     # only do this if running under the regression suite
  12.     raise ImportError, msg
  13.  
  14. done = 0
  15. for nismap in maps:
  16.     if verbose:
  17.         print nismap
  18.     mapping = nis.cat(nismap)
  19.     for k, v in mapping.items():
  20.         if verbose:
  21.             print '    ', k, v
  22.         if not k:
  23.             continue
  24.         if nis.match(k, nismap) <> v:
  25.             print "NIS match failed for key `%s' in map `%s'" % (k, nismap)
  26.         else:
  27.             # just test the one key, otherwise this test could take a
  28.             # very long time
  29.             done = 1
  30.             break
  31.     if done:
  32.         break
  33.